#! /bin/sh

# print all days in a year
# run as: sh get_year_days.sh [YEAR]

# if $1 provided, set year to $1, or set year to 2008
year=${1:-2008}

first_second=`date -d "$year-01-01" +%s`
last_second=`date -d "$year-12-31" +%s`
days=$(( ($last_second-$first_second)/86400 + 1 ))

echo "Year $year has $days days:";

# print all days
seq 0 $(( days - 1 )) | while read d
do
  date --date="$year-01-01 +$d days" +"%Y-%m-%d"
done
